<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.liufeng.course.util.*"%>
<%@ page language="java"
	import="java.sql.*,java.net.*,java.util.*,java.text.*,java.io.*,java.net.*"%>
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String x = request.getParameter("x");
String y = request.getParameter("y");
String name = request.getParameter("name");
String cont = URLDecoder.decode(StrTools.doNull(request.getParameter("cont")),"UTF-8");
if(StrTools.isEmpty(x)||StrTools.isEmpty(y)){
	out.print("<p style=\"font-size:24;\">暂无数据~~</p>");
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Ec2chH8MHnfQo9cUi0ga6jw9"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<title>百度地图</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">

// 百度地图API功能
//GPS坐标
var xx = "<%=x%>";
var yy = "<%=y%>";
var name = "<%=name%>";
var cont = "<%=cont%>";
var gpsPoint = new BMap.Point(xx,yy);

//地图初始化
var bm = new BMap.Map("allmap");
bm.centerAndZoom(gpsPoint, 12);
bm.addControl(new BMap.NavigationControl());

//添加谷歌marker和label
/*
var markergps = new BMap.Marker(gpsPoint);
bm.addOverlay(markergps); //添加GPS标注             // 将标注添加到地图中
markergps.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
var labelgps = new BMap.Label(name,{offset:new BMap.Size(20,-10)});
markergps.setLabel(labelgps); //添加GPS标注
*/
//坐标转换完之后的回调函数
translateCallback = function (point){
    var marker = new BMap.Marker(point);
    bm.addOverlay(marker);
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
    //var label = new BMap.Label("我是百度标注哦",{offset:new BMap.Size(20,-10)});
    //marker.setLabel(label); //添加百度label
    bm.setCenter(point);
    var opts = {
  		width : 150,     // 信息窗口宽度
  		height: 30,     // 信息窗口高度
 		title : name+"水库"  // 信息窗口标题
	}
	var infoWindow = new BMap.InfoWindow("地址："+cont, opts);  // 创建信息窗口对象
	bm.openInfoWindow(infoWindow,point); //开启信息窗口
}

setTimeout(function(){
    BMap.Convertor.translate(gpsPoint,0,translateCallback);     //真实经纬度转成百度坐标
}, 1000);


</script>
